/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.gov.fasepa.sgpf.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author marcosdj
 */
@Entity
@Table(name = "subsetor")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Subsetor.findAll", query = "SELECT s FROM Subsetor s ORDER BY s.sigla"),
    @NamedQuery(name = "Subsetor.findById", query = "SELECT s FROM Subsetor s WHERE s.id = :id"),
    @NamedQuery(name = "Subsetor.findByNome", query = "SELECT s FROM Subsetor s WHERE s.nome = :nome"),
    @NamedQuery(name = "Subsetor.findBySigla", query = "SELECT s FROM Subsetor s WHERE s.sigla = :sigla"),
    @NamedQuery(name = "Subsetor.findByRamal", query = "SELECT s FROM Subsetor s WHERE s.ramal = :ramal")})
public class Subsetor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @Basic(optional = false)
    @Column(name = "sigla")
    private String sigla;
    @Column(name = "ramal")
    private String ramal;
    @JoinColumn(name = "setor", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Setor setor;
    @JoinColumn(name = "responsavel", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Servidor responsavel;

    public Subsetor() {
    }

    public Subsetor(Integer id) {
        this.id = id;
    }

    public Subsetor(Integer id, String nome, String sigla) {
        this.id = id;
        this.nome = nome;
        this.sigla = sigla;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public String getSigla() {
        return sigla;
    }

    public void setSigla(String sigla) {
        this.sigla = sigla;
    }

    public String getRamal() {
        return ramal;
    }

    public void setRamal(String ramal) {
        this.ramal = ramal;
    }

    public Setor getSetor() {
        return setor;
    }

    public void setSetor(Setor setor) {
        this.setor = setor;
    }

    public Servidor getResponsavel() {
        return responsavel;
    }

    public void setResponsavel(Servidor responsavel) {
        this.responsavel = responsavel;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subsetor)) {
            return false;
        }
        Subsetor other = (Subsetor) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Subsetor[ id=" + id + " ]";
    }
    
}
